import request from '@/utils/request'

// 获取购物车列表
export const getCartItems = (userId) => {
  return request({
    url: `/cart/list?userId=${userId}`,
    method: 'get'
  })
}

// 添加商品到购物车
export const addToCart = (userId, data) => {
  return request({
    url: `/cart/add?userId=${userId}`,
    method: 'post',
    data
  })
}

// 更新购物车商品数量
export const updateCartItem = (userId, cartItemId, quantity) => {
  return request({
    url: `/cart/${cartItemId}/quantity?userId=${userId}&quantity=${quantity}`,
    method: 'put'
  })
}

// 删除购物车商品
export const removeCartItem = (userId, cartItemId) => {
  return request({
    url: `/cart/${cartItemId}?userId=${userId}`,
    method: 'delete'
  })
}

// 清空购物车
export const clearCart = (userId) => {
  return request({
    url: `/cart/clear?userId=${userId}`,
    method: 'delete'
  })
}

// 获取购物车商品总数
export const getCartCount = (userId) => {
  return request({
    url: `/cart/count?userId=${userId}`,
    method: 'get'
  })
} 